
var addressInit = function(_carea,_cmbProvince, _cmbCity, _cmbArea,defaultarea1, defaultProvince, defaultCity, defaultArea)
{
	var area=document.getElementById(_carea);
	var cmbProvince = document.getElementById(_cmbProvince);
	var cmbCity = document.getElementById(_cmbCity);
	var cmbArea = document.getElementById(_cmbArea);
	function cmbSelect(cmb, str)
	{
		for(var i=0; i<cmb.options.length; i++)
		{
			if(cmb.options[i].value == str)
			{
				cmb.selectedIndex = i;
				return;
			}
		}
	}
	function cmbAddOption(cmb, str, obj)
	{
		var option = document.createElement("OPTION");
		option.innerHTML = str;
		option.value = str;
		option.obj = obj;
		cmb.options.add(option);
	}
	
	function changeCity()
	{
		cmbArea.options.length = 0;
		if(cmbCity.selectedIndex == -1)return;
		var item = cmbCity.options[cmbCity.selectedIndex].obj;
		for(var i=0; i<item.areaList.length; i++)
		{
			cmbAddOption(cmbArea, item.areaList[i], null);
		}
		cmbSelect(cmbArea, defaultArea);
	}
	function changeProvince()
	{
		cmbCity.options.length = 0;
		cmbCity.onchange = null;
		if(cmbProvince.selectedIndex == -1)return;
		
		var item = cmbProvince.options[cmbProvince.selectedIndex].obj;
		for(var i=0; i<item[cmbProvince.selectedIndex].cityList.length; i++)
		{
			cmbAddOption(cmbCity, item[cmbProvince.selectedIndex].cityList[i].name, item[cmbProvince.selectedIndex].cityList[i]);
		}
		cmbSelect(cmbCity, defaultCity);
		changeCity();
		cmbCity.onchange = changeCity;
	}
	function changeArea()
	{
		cmbProvince.options.length = 0;
		cmbProvince.onchange = null;
		if(area.selectedIndex == -1)return;
		var item=area.options[area.selectedIndex].obj;
		for(var i=0;i<item.Allcity.length;i++)
		{
			cmbAddOption(cmbProvince,item.Allcity[i].name,item.Allcity);
		}
		cmbSelect(cmbProvince,defaultProvince);
		changeProvince();
		cmbProvince.onchange=changeProvince;
	}
		
		
		
		
	for(var i=0; i<provinceList.length; i++)
	{
	//alert(provinceList[i].Allcity[0].name);
	//var mess=provinceList[i].Allcity.join('--');
	//alert(mess);
		cmbAddOption(area, provinceList[i]._area, provinceList[i]);
	}
	
	cmbSelect(area, defaultarea1);
	changeArea();
	area.onchange = changeArea;
}

var provinceList = [
{_area:"请选择省份",Allcity:[{name:'请选择市',cityList:[{name:'请选择区/县',areaList:['请选择街道']}]}]},                   
{_area:"江苏",Allcity:[

{name:'请选择市', cityList:[		   
{name:'请选择区/县', areaList:['请选择街道']}
]},

{name:'无锡市', cityList:[		   
{name:'请选择区/县', areaList:['请选择街道']},		   
{name:'无锡市', areaList:['请选择街道','崇安区','南长区']},		   
{name:'徐州市', areaList:['请选择街道','鼓楼区','云龙区']}		   

]}]},
              
{_area:"上海",Allcity:[

{name:'请选择市', cityList:[		   
{name:'请选择区/县', areaList:['请选择街道']}
]},

{name:'上海市', cityList:[		   
{name:'请选择区/县', areaList:['请选择街道']},		   
{name:'无锡市1', areaList:['请选择街道','崇安区1','南长区1']},		   
{name:'徐州市1', areaList:['请选择街道','鼓楼区1','云龙区1']}		   

]}]}
];